
let db = require("../db/index");
 
exports.all = (req, res) => {
    var sql =
        "select * from user";
    db.query(sql, [], (err, data) => {
        if (err) {
            console.log("出错了", err);
            return res.send("错误" + err.message);
        }
        res.send(data);
    });
};
 
//删除人员
exports.del = (req, res) => {
    var sql = "delete from t_user where id = ?";
    db.query(sql, [req.body.id], (err, data) => {
        if (err) {
            console.log("出错了", err);
            return res.send("错误" + err);
        }
        res.send(data);
    });
};
 
//更新
exports.update = (req, res) => {
    var sql =
        "update t_user set name = ?,mobile=?,idNo=?,sex=?,noteText=?,groupId=? where id = ?";
    db.query(
        sql,
        [
            req.body.name,
            req.body.mobile,
            req.body.idNo,
            req.body.sex,
            req.body.noteText,
            req.body.groupId,
            req.body.id,
        ],
        (err, data) => {
            if (err) {
                console.log("出错了", err);
                return res.send("错误" + err);
            }
            res.send(data);
        }
    );

};